package com.nandi.deviceinstall.ui.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.nandi.deviceinstall.R
import com.nandi.deviceinstall.bean.ListDataBean

class DataAdapter: BaseQuickAdapter<ListDataBean.DataBean.MonitoringDataBean, BaseViewHolder> {
    private var sb = StringBuffer()

    constructor(layoutResId: Int) : super(layoutResId)

    override fun convert(helper: BaseViewHolder, item: ListDataBean.DataBean.MonitoringDataBean?) {
        sb.delete(0,sb.length)
        helper.setText(R.id.time,item?.timestamp)
        if (!(item?.nowXValue as String?).isNullOrEmpty()){
            sb.append("X轴:${item?.nowXValue}${item?.nowXUnit},")
        }
        if (!(item?.nowYValue as String?).isNullOrEmpty()){
            sb.append("Y轴:${item?.nowYValue}${item?.nowYUnit},")
        }
        if (!(item?.nowZValue as String?).isNullOrEmpty()){
            sb.append("Z轴:${item?.nowZValue}${item?.nowZUnit},")
        }
        if (!(item?.shiftXValue as String?).isNullOrEmpty()){
            sb.append("X轴方向位移:${item?.shiftXValue}${item?.shiftXUnit},")
        }
        if (!(item?.shiftYValue as String?).isNullOrEmpty()){
            sb.append("Y轴方向位移:${item?.shiftYValue}${item?.shiftYUnit},")
        }
        if (!(item?.shiftZValue as String?).isNullOrEmpty()){
            sb.append("Z轴方向位移:${item?.shiftZValue}${item?.shiftZUnit},")
        }
        if (!(item?.heightValue as String?).isNullOrEmpty()){
            sb.append("空高:${item?.heightValue}${item?.heightUnit},")
        }
        if (!(item?.nowPullLineValue as String?).isNullOrEmpty()){
            sb.append("拉线:${item?.nowPullLineValue}${item?.nowPullLineUnit},")
        }
        if (!(item?.rainfallValue as String?).isNullOrEmpty()){
            sb.append("雨量:${item?.rainfallValue}${item?.rainfallUnit}")
        }

        helper.setText(R.id.data,sb.toString())
    }
}
